<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, initial-scale=1.0, width=device-width"/>
    <meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
    <title>首页</title>
    <link rel="stylesheet" type="text/css" href="../../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../../css/main.css" />
</head>
<body>
  <div id="header">
      <div id="back"></div>
      <h3>联系人列表</h3>
  </div>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/jquery.js"></script>
<script type="text/javascript">
apiready=function(){
  var aid=$api.getStorage("aid");
    //判断是否为项目经理
  var flag=$api.getStorage("flag");
  var url="";
  var pmAid="";
  var PMname="";
  if(flag==3){
    url='/api/oto-chats/pmContactList?page=0&size=10&pmAid='+aid;
  }else{
    url='/api/oto-chats/userList?userAid='+aid+'&page=0&size=10';
  }
  var functionRet=function(ret){
    if(ret==""){
      toast("对不起，该联系人不在","middle");
    }else{
      //alert(ret.list[0].chatRoomId);
      var common=[];
      $.each(ret.list, function(commentIndex, comment){
          //alert( commentIndex + ": " + comment.userImInfoVo.nickname );
              var mana={
                placeholderImg: 'widget://res/img/ic/listContact.png',
                img: comment.userImInfoVo.headImagesUrl,
                title: comment.userImInfoVo.nickname,
                titleSize:16,
                titleColor:'#777'
              };
              common.push(mana);
           });
      var listContact = api.require('listContact');
      listContact.open({
        h: api.frameHeight,
        x:0,
        y:60,
        cellBgColor:'#fff',
        cellHeight:'70',
        rightBtn: [{
            color: '#8B0000',
            title: '备注'
        }],
        data: {
            common:common
        }
        }, function(ret2, err) {
            if (ret2) {
                var retIndex=ret2.index;
                  api.openWin({
                      name: 'chat',
                      url: 'chat.html',
                      pageParam: {
                          PMname: ret.list[retIndex].userImInfoVo.nickname,
                          PMaid:ret.list[retIndex].aid,
                          chatRoomId:ret.list[retIndex].chatRoomId
                  }
                });
            } else {
                alert(JSON.stringify(err));
            }
        });
        }
    }
  var functionErr=function(err){
    //toast("对不起，该公司项目经理不在","middle");
  }
  get(url,functionRet,functionErr);

  }

$(function(){
  back();
})
</script>
<script type="text/javascript" src="../../script/main.js"></script>
</html>
